Previous topicNext topic
Help > Creating Dynamic Link Libraries >
Private and Exported Procedures

There are two basic types of procedures in a DLL: private and exported. Exported procedures are those which are made available to applications and other DLLs. Private, or local, procedures are support-type routines, accessible only from within the DLL.

In the following example, the first procedure defines an exported Sub that accepts two arguments: a string and an Integer. The second procedure defines an exported function that accepts a single string argument, and returns an Integer. Finally, the third procedure defines a private Sub that accepts a single Integer argument. The first two routines are callable from an external .EXE or another DLL. The third one is not.

#COMPILE DLL

SUB MySub (sArg AS STRING, BYVAL iArg AS INTEGER) EXPORT

 ' Body goes in here

END SUB

FUNCTION MyFunc (sArg AS STRING) EXPORT AS INTEGER

 ' Body goes in here

END FUNCTION

SUB MyPrivateSub(BYVAL iArg AS INTEGER)

 ' Body goes in here

END SUB

Alternatively, you may specifically declare Subs and Functions as private, by using the PRIVATE keyword:

SUB MyPrivateSub(BYVAL iArg AS INTEGER) PRIVATE

 ' Body goes in here

END SUB

 

See Also

What is a Dll?

Creating a Dynamic Link Library

Dll example

LibMain

What is an object, anyway?

Just what is COM?

What is a COM component?